package cn.doit.scala.day05.high_function

import scala.util.Random

/**
 * @DATE 2021/12/30/14:55
 * @Author MDK
 * @Version 2021.2.2
 * */
object C03_Match01 {
  def main(args: Array[String]): Unit = {
    val list = List[Any](1, 2, 3, 4, "hello", "java", "hive", "Scala", User(1, "zss", 23))
    val random = new Random()
    val i = random.nextInt(list.length)
    println(i)

    val e: Any = list(i)
    val value = e match {
      case e: Int => e * e
      case e: String => e.toUpperCase
      case e: User => println(s"这是一个user类型 ${e.name}")
    }
    println(value)
  }
}
